<?php

namespace App\Models;


class ChatRoomMessage extends Model
{
    use ModelTrait;

    protected $table = 'chat_room_message';

    /**
     * The attributes that are mass assignable.
     *
     * @var array<int, string>
     */
    protected $fillable = [
        'id',
        'chat_room_id',
        'from_member_id',
        'to_member_id',
        'message',
        'created_at',
        'updated_at',
    ];

    public function chat_room()
    {
        return $this->belongsTo(ChatRoom::class,'chat_room_id','id');
    }

    public function from_member()
    {
        return $this->belongsTo(Member::class,'from_member_id','id');
    }

    public function to_member()
    {
        return $this->belongsTo(Member::class,'to_member_id','id');
    }

    public function is_receive()
    {
        return $this->belongsTo(Member::class,'to_member_id','id');
    }

    public function is_send()
    {
        return $this->belongsTo(Member::class,'from_member_id','id');
    }
}
